﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace OpenComposite.Controls
{
	/// <summary>
	/// An extended DateTimePicker to select Date AND Time.
	/// </summary>
	public partial class DateTimePickerEx : UserControl
	{
		public DateTimePickerEx()
		{
			InitializeComponent();
			Value = DateTime.Now;
		}

		public event EventHandler ValueChanged;

		public bool ShowCheckBox
		{
			get { return dtpDate.ShowCheckBox; }
			set { dtpDate.ShowCheckBox = value; }
		}

		public bool Checked
		{
			get { return dtpDate.Checked; }
			set { dtpDate.Checked = value; }
		}

		public DateTime Value
		{
			get { return dtpDate.Value.Date + dtpTime.Value.TimeOfDay; }
			set
			{
				dtpDate.Value = value.Date;
				dtpTime.Value = value;
			}
		}

		private void dtpDate_ValueChanged(object sender, EventArgs e)
		{
			EventHandler tmp = this.ValueChanged;
			if ( tmp != null ) tmp(sender, e);
		}
	}
}
